package com.singzi.testCase;

public class BinaSearch {

    public static void main(String[] args) {
        double[] nums = new double[10];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = i + 0.5;
        }
        System.out.println(binaSearch(nums, 8));
    }
    public static int binaSearch(double[]nums, int target){
        int left = 0;
        int right = nums.length-1;
        while (left<right){
            int mid = left + (right-left)/2;

            if (target > nums[mid])
                left = mid + 1;
            else
                right = mid;
        }
        return left;
    }
}
